import { defineAmisPlugin, getExtendProps, getInputTpl } from '../../base/util';
import CommonFunction, { type IProps } from './fc';

export default defineAmisPlugin<IProps>(({ amisEditor }) => {
  const { getSchemaTpl } = amisEditor;

  return {
    component: CommonFunction,
    options: {
      type: 'portal-common-function',
      name: '常用功能',
      icon: 'AppstoreOutlined',
      description: '自定义常用功能',
      panelTitle: '常用功能',
      scaffold: {
        commonTitle: '最常使用',
        recentlyTitle: '最近使用',
      },
      panelTabs: [
        {
          title: '常规',
          body: [
            getSchemaTpl('collapseGroup', [
              {
                title: '基本',
                body: [
                  getInputTpl('commonTitle', { label: '标题1' }),
                  getInputTpl('recentlyTitle', { label: '标题2' }),
                  getExtendProps(),
                ],
              },
            ]),
          ],
        },
        {
          title: '外观',
          body: [
            getSchemaTpl('collapseGroup', [
              ...getSchemaTpl('theme:common', { styleName: 'style' }),
            ]),
          ],
        },
      ],
    },
  };
});
